<?php


class PaiementManager {
    public function __construct(Mypdo $db){
        $this->db= $db;
    }

    public function add(Paiement $pai){
        $req = $this->db->prepare('INSERT INTO mode_paiement ( libelle_pai ) VALUES
                  ( :libelle_pai )');
        $req->bindValue(':libelle_pai', $pai->getLibellePai(), PDO::PARAM_STR);

        $req->execute();

    }


    public function getList(){
        $listePai = array();
        $sql = 'SELECT * FROM mode_paiement ORDER BY id_pai';
        $req = $this->db->query($sql);
        while ($pai = $req->fetch(PDO::FETCH_OBJ)){
            $listePai[] = new Paiement($pai);
        }
        $req->closeCursor();
        return $listePai;

    }
} 